package com.leaf.u_spring.chapter03;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class MagicExistsConditional implements Condition {

	/**
	 * 方法简单功能强大
	 */
	@Override
	public boolean matches(ConditionContext ctxt, AnnotatedTypeMetadata metadata) {
		Environment env = ctxt.getEnvironment();
		//检查magic属性
		return env.containsProperty("magic");
	}

}
